<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Mimportant extends Model {

    function Mimportant() {
        parent::Model();
    }

    function get_important_detail($id){}

    function get_important_by_orderid($orderid){
    	$this->db->where('orderid',$orderid);
    	$query = $this->db->get('important');
    	return $query->row_array();
    }

    function check_important_exists($orderid){
    	$this->db->where('orderid',$orderid);
    	$query = $this->db->get('important');
    	$row = $query->row_array();
    	return empty($row) ? false : true;
    }

    function save_important($values){
    	$flag = $this->check_important_exists($values['orderid']);
    	if($flag){
            $orderid = $values['orderid'];
            unset($values['id']);
            unset($values['orderid']);
    		return $this->db->update('important',$values,array('orderid'=>$orderid));
    	} else {
    		return $this->db->insert('important',$values);
    	}
    }

	//打款信息
	function remit_money_info($order_id){
		//A:根据order_id找到代练人员  B:根据代练人员找到a.代打人员真实姓名b.银行名称c.银行帐号d.电话  信息
		$sql="select * from mc_members where username=(select dai from mc_orders where order_id=$order_id)";
        $query=$this->db->query($sql);
    	return $query->row_array();
	}

}
?>